/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BLL;

import DAL.DALManu;
import DTO.DTOManufacture;
import java.util.ArrayList;
import javax.swing.DefaultComboBoxModel;

/**
 *
 * @author Pham
 */
public class BLLManu {
    DALManu manu;
    
    public BLLManu()
    {
        manu = new DALManu();
    }
    
    //method get all manufacture with model
    public DefaultComboBoxModel getDcbModelManu()
    {
        try{
            DefaultComboBoxModel model = new DefaultComboBoxModel();
            for(DTO.DTOManufacture itemManu : manu.getAllManu())
            {
                model.addElement(itemManu);
            }
            return model;
        }
        catch(Exception ex)
        {
            System.err.printf(ex.getMessage());
            return null;
        }
    }

    //method get Manu by ID
    public DTOManufacture getManuByID(int ID) {
        return manu.getManuByID(ID);
    }
    
    //method get all manufactures
    public ArrayList<DTOManufacture> getmanufactures()
    {
        return manu.getAllManu();
    }
    
    //method insert a new manufacture
    public boolean insertManu(DTOManufacture dtoManu)
    {
        return manu.insertNewManu(dtoManu);
    }
    
    //method update a manufacture
    public boolean updateManu(DTOManufacture dtoManu)
    {
        return manu.updateManu(dtoManu);
    }
    
    //method delete a maufacture
    public boolean deleteManu(int idManu)
    {
        return manu.deleteManu(idManu);
    }
}
